﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Entities;
using System.Configuration;

namespace DataAccess
{
   public  class MoneyDA
    {
        ConnectDB cn = new ConnectDB();
        MoneyEntites moneyE = new MoneyEntites();
        //QuocPN
        public bool CheckWithdraw(MoneyEntites moneyE)
        {
            bool kt = false;
            SqlConnection con = new SqlConnection(cn.ConnectionString());
            con.Open();
            SqlCommand cmd = new SqlCommand("Withdaw", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@Amount", moneyE.MoneyValue));
            SqlDataReader dt = cmd.ExecuteReader();
            cmd.Dispose();
            return kt;
        }
        //QuocPN
        public Decimal getMoneyValue()
        {
            SqlConnection con = new SqlConnection(cn.ConnectionString());
            con.Open();
            SqlCommand cmd = new SqlCommand("Select_MoneyValue", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.ExecuteNonQuery();
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            da.Fill(dt);
            string x = dt.Rows[0][0].ToString();
            Decimal moneyvalue = Decimal.Parse(x);
            return moneyvalue;


        }
    }
}
